package com.hunan.chinamobile.service.impl;

import com.hunan.chinamobile.dao.DeviceMapper;
import com.hunan.chinamobile.dto.DeviceDTO;
import com.hunan.chinamobile.model.Device;
import com.hunan.chinamobile.service.DeviceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DeviceServiceImpl implements DeviceService {

    @Resource
    private DeviceMapper deviceMapper;

    @Override
    public void save(Device model) {
        deviceMapper.insert(model);
    }

    @Override
    public void deleteById(String id) {
        deviceMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Device model) {
        deviceMapper.updateByPrimaryKeySelective(model);
    }

    @Override
    public Device findById(String id) {
        return deviceMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<DeviceDTO> findList(String cityId, String bsId, String deviceName, Integer online, Integer state) {
        return deviceMapper.findList(cityId, bsId, deviceName,online, state);
    }

    @Override
    public List<Device> findAll() {
        return deviceMapper.selectAll();
    }

    @Override
    public DeviceDTO findDTO(String deviceId) {
        return deviceMapper.findDTO(deviceId);
    }

    @Override
    public int findDeviceCount(String bsId) {
        return deviceMapper.findDeviceCount(bsId);
    }

    @Override
    public Device findByDeviceId(String deviceId) {
        return deviceMapper.findByDeviceId(deviceId);
    }

    @Override
    public int delById(String id) {
        return deviceMapper.delById(id);
    }

    @Override
    public Device findByName(String deviceName) {
        return deviceMapper.findByName(deviceName);
    }

    @Override
    public int updateOnlineByOneNetId(int status, int devId) {
        return deviceMapper.updateOnlineByOneNetId(status, devId);
    }
}
